<template>
  <div class="PaiHang">
    <UserList v-for="(item, index) in Obj" :key="index" :Obj="item" />
  </div>
</template>
<script>
// @ 是 /src 的别名
import UserList from "@/components/UserList.vue";
import { findByLikes } from "@/api/dream/dream";

export default {
  name: "LikesSortedView",
  components: {
    UserList
  },

  data() {
    return {
      Obj: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10
      }
    };
  },

  // computed会缓存结果，methods每次都会重新计算
  methods: {
    getList() {
      findByLikes(this.queryParams)
        .then(res => {
          if (res.data.code == 200) {
            this.Obj = res.data.data.list;
          }
        })
        .catch(error => {
          this.$message({
            message: "获取页面内容失败！",
            type: "error",
            duration: 2000
          });
          console.log("获取排行出错！");
          console.error(error);
        });
    }
  },

  created() {
    this.getList();
  }
};
</script>
